#include "helpscreen.h"


#include <wiiuse/wpad.h>

#include <ogcsys.h>
#include <gccore.h>

extern u8 help_1_png[];
extern u8 help_2_png[];
extern u8 help_3_png[];

HelpScreen::HelpScreen()
{
	_helpImages.push_back(new Image());
	if(_helpImages[0]->LoadImage(help_1_png, IMG_LOAD_TYPE_BUFFER) != IMG_LOAD_ERROR_NONE)exit(0);
	
	_helpImages.push_back(new Image());
	if(_helpImages[1]->LoadImage(help_2_png, IMG_LOAD_TYPE_BUFFER) != IMG_LOAD_ERROR_NONE)exit(0);
	
	_helpImages.push_back(new Image());
	if(_helpImages[2]->LoadImage(help_3_png, IMG_LOAD_TYPE_BUFFER) != IMG_LOAD_ERROR_NONE)exit(0);
	
	_helpSprite.SetPosition(0,0);
	_helpSprite.SetImage(_helpImages[0]);
	
	_pageIndex = 0;
}

HelpScreen::~HelpScreen()
{

}
		
bool HelpScreen::Update()
{

	WPAD_ScanPads();
	
	u16 btnsdown = WPAD_ButtonsDown(0);

	if(btnsdown & WPAD_BUTTON_A || btnsdown & WPAD_BUTTON_RIGHT)
	{
		_pageIndex++;
		_pageIndex = _pageIndex % _helpImages.size();
	}
	
	if(btnsdown & WPAD_BUTTON_LEFT)
	{
		if(_pageIndex == 0)
			_pageIndex = _helpImages.size() - 1;
		else
			_pageIndex--;
	}
	
	if(btnsdown & WPAD_BUTTON_B || btnsdown & WPAD_BUTTON_HOME)
	{
		_pageIndex = 0;
		return false;
	}
	
	
	_helpSprite.SetImage(_helpImages[_pageIndex]);
	_helpSprite.Draw();
	
	return true;
}
